#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "../intLinkStack.c"
int calc(char const *expr){
    LinkStack s=NULL;
    int i=0,a,b,c,result;
    char ch;
    ch=expr[0];i++;
    while(ch!='\0'){
        if(!strchr("+-*/%()",ch)){
            printf("push %d\n",ch-48);
            s=Push_LinkStack(s,ch-48);
        }
        else{
            s=Pop_LinkStack(s,&b);
            s=Pop_LinkStack(s,&a);
            switch (ch)
            {
                case '+':c=a+b;break;
                case '-':c=a-b;break;
                case '*':c=a*b;break;
                case '/':c=a/b;break;
                case '%':c=a%b;break;
            }
            printf("%d%c%d=%d\n",a,ch,b,c);
            printf("push %d\n", c);
            s=Push_LinkStack(s,c);
        }
        ch=expr[i];i++;
    }
    s=Pop_LinkStack(s,&result);
    return result;
}
int main(int argc,char const *argv[]){

    printf("calc(\"32422*+13*-*5-\")=%d", calc("32422*+13*-*5-"));
    getchar();
    return 0;
}